package com.gitee.wsl.ext.map


inline fun <K, V, R> Map<K, V>.flatMap(transform: (Map.Entry<K, V>) -> Array<R>): List<R> {
    return flatMapTo(ArrayList<R>(), transform)
}

inline fun <K, V, R, C : MutableCollection<in R>> Map<K, V>.flatMapTo(destination: C, transform: (Map.Entry<K, V>) -> Array<R>): C {
    for (element in this) {
        val list = transform(element)
        destination.addAll(list)
    }

    return destination
}